using UnityEngine;
using System.Collections;

public class ShiftRandomSprite : MonoBehaviour {
	
	public int frameInterval;	
	
	private UISprite targetSprite;
	private int elapsedFrame = 0;
	private int recentFrame = 0;
	
	// Use this for initialization
	void Start()
	{
		targetSprite = gameObject.GetComponent<UISprite>();
	}
	
	// Update is called once per frame
	void Update()
	{
		elapsedFrame++;
		if(elapsedFrame >= frameInterval)
		{
			elapsedFrame = 0;
			recentFrame++;
			if(recentFrame >= 4)
				recentFrame -= 4;
			
			//int randomValue = Random.Range(0, 4);
			string name = targetSprite.atlas.spriteList[recentFrame].name;
			targetSprite.spriteName = name;
		}
		
	}
}
